package dao

import (
	"express/global"
	"express/internal/model"
)

func CreateRecord(p model.Parcel) error {
	return global.DBEngine.Create(&p).Error
}

func GetRecorder(phone string) ([]model.Parcel, error) {
	var list []model.Parcel
	err := global.DBEngine.Where("user_to = ?", phone).Find(&list).Error
	return list, err
}

func GetRecorderBySender(phone string) ([]model.Parcel, error) {
	var list []model.Parcel
	err := global.DBEngine.Where("user_from = ?", phone).Find(&list).Error
	return list, err
}
